package by.yakusekmaxim.bookgid.services;

import java.util.List;

import javax.persistence.metamodel.SingularAttribute;
import javax.transaction.Transactional;

import by.yakusekmaxim.bookgid.dataaccess.util.Filter;
import by.yakusekmaxim.bookgid.datamodel.Book;
import by.yakusekmaxim.bookgid.datamodel.UserAccount;
import by.yakusekmaxim.bookgid.services.util.CrudMessage;

public interface BookService {
	
	Book get(Long id);

    @Transactional
    CrudMessage saveOrUpdate(Book book, UserAccount user);
    
    @Transactional
    CrudMessage delete(Book book,UserAccount user);
    @Transactional
    void delete(Book book);

    @Transactional
    void deleteAll();
    
    @Transactional
	void saveOrUpdate(Book book);
    
    @Transactional
	Long getCount();

	@Transactional
	Long getCount(SingularAttribute<Book, ?> attribute, Object value);
	
	@Transactional
	List<Book> getAllBook(SingularAttribute<Book, ?> attr,
			boolean ascending, int startRecord, int pageSize);

	@Transactional
	List<Book> getAllBook(SingularAttribute<Book, ?> attr,
			boolean ascending, int startRecord, int pageSize,
			Filter<Book> filter);
	
	@Transactional
	List<Book> getAllPublicBook(SingularAttribute<Book, ?> attr,
			boolean ascending, int startRecord, int pageSize);

	@Transactional
	List<Book> getAllPublicBook(SingularAttribute<Book, ?> attr,
			boolean ascending, int startRecord, int pageSize,
			Filter<Book> filter);
}
